/* app/configureStore.js */

import {
    compose, createStore, applyMiddleware
}
from 'redux';
//在Redux中，Middleware 主要是负责改变Store中的dispatch方法，
//从而能处理不同类型的 action 输入，得到最终的 Javascript Plain Object 形式的 action 对象。
// applyMiddleware
//import reduxDevtools from 'redux-devtools';

//import ReactDevTools from './utils/ReactDevTools';

import promiseMiddleware from './utils/middleware/promise';
import transformResponseData from './utils/middleware/transformResponseData';


let buildStore;
//if(__DEBUG__) {
// if (false) {
//     buildStore = compose(
//         applyMiddleware(promiseMiddleware,transformResponseData),
//         reduxDevtools.devTools(),
//         reduxDevtools.persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
//         createStore
//     )
// } else {
//     buildStore = compose(
//         applyMiddleware(promiseMiddleware,transformResponseData),
//         ReactDevTools.instrument()
//     )(createStore)
// }
// 
buildStore = compose(
    applyMiddleware(promiseMiddleware,transformResponseData)
)(createStore)


export default function configureStore(rootRenducer,initialState) {
    return buildStore(rootRenducer,initialState);
}